package com.hxzy.tms.action;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.hxzy.tms.entity.Team;
import com.hxzy.tms.entity.TeamUser;
import com.hxzy.tms.entity.User;
import com.hxzy.tms.entity.UserTask;
import com.hxzy.tms.service.TaskService;
import com.hxzy.tms.service.TeamService;
import com.hxzy.tms.service.UserService;

public class UserAction extends AbstractAction {

    private static final long serialVersionUID = -2486010874819783313L;
    
    private String id;
    private UserService userService;
    private TeamService teamService;
    private TaskService taskService;
    
    public String index(){
        if(id==null||StringUtils.isBlank(id)){
            return _404();
        }
        Long _id=new Long(id);
        User user=userService.read(_id).data;
        if(user==null){
            return _404();
        }
        assign("user", user);
        //用戶创建的团队
        List<Team> teams=teamService.createUser(_id, null).data;
        assign("teams", teams);
        //用户加入的团队
        List<TeamUser> userTeams=teamService.userJionTeam(_id).data;
        assign("userTeams", userTeams);
        List<UserTask> userTasks=taskService.taskList(_id).data;
        assign("userTasks", userTasks);
        
        return INPUT;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public TeamService getTeamService() {
        return teamService;
    }

    public void setTeamService(TeamService teamService) {
        this.teamService = teamService;
    }

    public TaskService getTaskService() {
        return taskService;
    }

    public void setTaskService(TaskService taskService) {
        this.taskService = taskService;
    }
    
    
}
